/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Extras.GestorEstilos;
import java.awt.Label;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 *
 * @author Jose
 */
public class TarjetaF extends javax.swing.JFrame {

    /**
     * Creates new form Tarjeta
     */
    private Thread tarea;

    public TarjetaF() {
        this.setUndecorated(true);
        initComponents();
        setLocationRelativeTo(null);
        GestorEstilos.pintar(this);
        this.getRootPane().putClientProperty("Synthetica.titlePane.enabled", false);
    }

    public void seleccionarTarjeta(String ruta) {
        this.label.setIcon(new ImageIcon(getClass().getResource("/Imagenes/TarjetasSuerteArcaComunal/" + ruta)));
        this.setAlwaysOnTop(true);
        this.setVisible(true);
        Runnable tarjetas = new Runnable() {
            public void run() {
                try {
                    Thread.sleep(6000);
                    dispose();
                } catch (Exception e) {
                    System.out.println("No se ha podido pausar la tarea.");
                }
                tarea.stop();
            }
        };
        tarea = new Thread(tarjetas);

    }

    public void star() {
        tarea.start();
    }

    public void stop() {
        tarea.stop();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(label, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel label;
    // End of variables declaration//GEN-END:variables
}
